<template>
  <div class="logo_box" @click="goHome">
    <img src="/resource/img/niu.png" alt="logo" :style="{ width: logoSize, height: logoSize }" />
    <label :style="{ fontSize, color }" v-show="showTitle">NiuAdmin</label>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { useRouter } from 'vue-router'

export default defineComponent({
  name: 'AppLogo',
  props: {
    showTitle: {
      type: Boolean,
      default: true
    },
    fontSize: {
      type: String,
      default: '24px'
    },
    color: {
      type: String
    },
    logoSize: {
      type: String,
      default: '50px'
    }
  },
  setup() {
    const router = useRouter()

    function goHome() {
      router.push({
        path: '/'
      })
    }

    return {
      goHome
    }
  }
})
</script>

<style scoped lang="scss">
.logo_box {
  display: flex;
  align-items: center;
  cursor: pointer;

  img {
    vertical-align: bottom;
    margin-left: -5px;
    margin-right: 5px;
  }

  label {
    font-weight: bold;
    cursor: pointer;
  }
}
</style>
